package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;


public class FilmViewPage extends InternalPage {

	public FilmViewPage(PageManager pages) {
		super(pages);
	}
	
	@FindBy(xpath = ".//*[@class='maininfo_full']/h2")
	private WebElement MainInfoField;
  
  @FindBy(xpath = ".//*[@class='duration']")
  private WebElement durationField;
  
  @FindBy(xpath = ".//*[@class='maininfo_full']/div[5]")
  private WebElement languagesField;
  
  @FindBy(xpath = ".//*[@class='country']")
  private WebElement countryField;
  
  @FindBy(css = "img[alt=\"Remove\"]")
  private WebElement removeButton;

  public String getMainInfo() {
    return MainInfoField.getText();
  }


  public String getDuration() {
	    return durationField.getText();
	  }


  public String getLanguages() {
	  return languagesField.getText();
  }

  public String getCountry() {
	  return countryField.getText();
  }
  
  public FilmListPage clickRemoveButton() {
		removeButton.click();
		wait.until(alertIsPresent()).accept();
		return pages.FilmListPage;
	}
  public FilmViewPage ensurePageLoaded() {
    super.ensurePageLoaded();
    wait.until(presenceOfElementLocated(By.className("maininfo_full")));
    return this;
  }


}
